package com.sgxy.service.impl;

import com.sgxy.entity.UserInf;
import com.sgxy.mapper.UserInfMapper;
import com.sgxy.service.UserInfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class UserInfServiceImpl implements UserInfService {

    private final UserInfMapper userInfMapper;
    @Autowired
    public UserInfServiceImpl(UserInfMapper userInfMapper) {
        this.userInfMapper = userInfMapper;
    }

    @Override
    public int addUserInf(UserInf userInf) {
        int i = userInfMapper.insertSelective(userInf);
        return i;
    }

    @Override
    public void deleteUserInf(Integer[] ids) {
        for (int i = 0; i < ids.length; i++) {
            int id = ids[i];
            userInfMapper.deleteByPrimaryKey(id);
        }
    }

    @Override
    public int updateUserInf(UserInf userInf) {
        int i = userInfMapper.updateByPrimaryKeySelective(userInf);
        return i;
    }

    @Override
    public UserInf queryUserInf(Integer id) {
        UserInf userInf = userInfMapper.selectByPrimaryKey(id);
        return userInf;
    }

    @Override
    public List<UserInf> queryAllUserInfs() {
        List<UserInf> userInfs = userInfMapper.selectAll();
        return userInfs;
    }

    @Override
    public UserInf queryUserInfByloginName(Example example) {

        UserInf userInf = userInfMapper.selectOneByExample(example);
        return userInf;
    }

    @Override
    public List<UserInf> queryAllUserInfsByConditon(Example example) {
        List<UserInf> userInfs = userInfMapper.selectByExample(example);
        return userInfs;
    }


}
